﻿import com.dmotiko.general.*
import com.dmotiko.util.MathUtils;
import com.dmotiko.zonaoutlet.*
import flash.display.*;
import mx.transitions.*;
import mx.transitions.easing.*;

class ZOPhotoOutlet
extends MovieLoaderClip {
	
	/* FLA MOVIECLIPS */
	private var mcImg:MovieClip;
	private var mcLoader:MovieClip;
	private var mcMask:MovieClip;
	//private var mcShadow:MovieClip;	
	
	private var rotationTween:Tween;
		
	private function initClip() {
		//mcShadow._alpha = 0;
		mcImg.setMask(mcMask);
		mcContainer = mcImg.createEmptyMovieClip("mcContainer", 1);
		super.initClip();
	}
		
	private function refreshData() {
		// data viene de XML
		loadContent( data.src );
	}
	
	public function onLoadProgress( target, loaded, total) {
		mcLoader.onEnterFrame = function() {
			var newWidth = this.mcBack._width * ( loaded / total );
			this.mcFront._width += (newWidth - this.mcFront._width) / 3;
			if ( loaded / total == 1) {
				this._visible = false;
				delete this.onEnterFrame;
			}
		}
		super.onLoadProgress();
	}
	
	public function onLoadInit( target:MovieClip ) {
		target._visible = false;
		var bitmap:BitmapData = new BitmapData( target._width, target._height, true);
		mcImg.attachBitmap( bitmap, mcImg.getNextHighestDepth(), "auto", true);
		bitmap.draw(target);
		rotationTween = new Tween( this, "_rotation", Elastic.easeOut, 0, 2, 1, true);
		super.onLoadInit();
	}
		
}